<?php
session_start();
include './config.php';

if (!isset($_SESSION['username'])) {
    header("Location: ../login.php");
    exit();
}

header('Content-Type: application/json');

$qq = $_GET['qq'] ?? '';

if (empty($qq)) {
    echo json_encode(["code" => "400", "msg" => "QQ号不能为空"]);
    exit();
}

$checkStmt = $conn->prepare("SELECT * FROM sq WHERE qq = ?");
$checkStmt->bind_param("s", $qq);
$checkStmt->execute();
$result = $checkStmt->GET_result();
$row = $result->fetch_assoc();

if ($row) {
    echo json_encode(["code" => "200", "data" => $row]);
} else {
    echo json_encode(["code" => "404", "msg" => "未找到授权信息"]);
}

$conn->close();
?>